package com.goldgov.code.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.goldgov.code.dao.FieldDao;
import com.goldgov.code.meta.Constraint;
import com.goldgov.code.meta.FieldInfo;
import com.goldgov.code.service.FieldService;

@Service
public class FieldServiceImpl implements FieldService{

	@Autowired
	private FieldDao fieldDao;
	
	@Override
	public void addField(FieldInfo field) {
		if(field.getConstraint() == null) {
			field.setConstraint(new Constraint());
		}
		fieldDao.addField(field);
	}

	@Override
	public void updateField(FieldInfo field) {
		fieldDao.updateField(field);
	}

	@Override
	public void deleteField(String[] ids) {
		fieldDao.deleteField(ids);
	}

	@Override
	public FieldInfo getField(String id) {
		return fieldDao.getField(id);
	}

	@Override
	public List<FieldInfo> listField(String moduleID) {
		return fieldDao.listField(moduleID);
	}

	@Override
	public long countField(int firstRow, int maxResult) {
		return fieldDao.countField(firstRow, maxResult);
	}

	@Override
	public void updateConstraintList(String fieldID, boolean isTrue) {
		fieldDao.updateConstraintList(fieldID, isTrue);
	}

	@Override
	public void updateConstraintRequired(String fieldID, boolean isTrue) {
		fieldDao.updateConstraintRequired(fieldID, isTrue);
	}

	@Override
	public void updateConstraintQueryType(String fieldID, String queryType) {
		fieldDao.updateConstraintQueryType(fieldID, queryType);
	}

}
